package application.model 
{
	import application.ApplicationFacade;
	import application.util.ResourceUtil;
	import application.view.MenuMediator;
	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.media.Sound;
	import flash.net.URLRequest;
	import flash.system.ApplicationDomain;
	import flash.system.LoaderContext;
	import org.puremvc.as3.patterns.proxy.Proxy
	import org.puremvc.as3.interfaces.IProxy;
	
	/**
	 * ...
	 * @author dragonWorrior
	 */
	public class resourceProxy extends Proxy implements IProxy
	{	
		public static var NAME:String = "resource_proxy";
		private var _clickSound:Sound;
		
		public function get clickSound():Sound
		{
			return _clickSound;
		}
		
		public function resourceProxy() 
		{
			loadUIResource();	
		}
		
		private function loadUIResource():void
		{
			var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
			loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
			loader.load(new URLRequest("ui.swf"));
		}
		
		private function initialSound():void
		{
			_clickSound = ResourceUtil.getSoundObject("shooting.sound.click");
		}
		
		private function onComplete(e:Event):void
		{
			ResourceUtil.uiResource = e.currentTarget as LoaderInfo;
			initialSound();
			sendNotification(MenuMediator.ADD_MENU);
		}
		
		private function onError(e:Event):void
		{
			trace("load ui failed");
		}
		
	}

}